import {
  createInbizSchema,
  createComponentStyleSchema,
  createDecoratorStyleSchema,
  createCommonMapStyle,
  createMapSchema,
  createColorSchemeSchema,
  createBizStyleSchema,
  createControllerSchema,
} from '@inbiz/setters';

export const defaultProps = {
  headerStyle: {
    icon: {
      type: 'icon-genzujian-bingtu',
    },
  },
  style: {
    height: '300px',
    padding: '0px 0px 0px 0px',
  },
  colorPattern: {
    index: 0,
    colorArray: ['#1989fa', '#fbd44b', '#40c5d6', '#6befae', '#889bea', '#eaa1ff', '#a1fcff'],
  },
  detailView: 'none',
  mapBackground: {
    style: {
      backgroundColor: '',
      backgroundImage: '',
    },
  },
  dataLabel: ['type', 'ratio'],
  titlePosition: 'top',
  legendPosition: 'right',
  maptitleColor: 'rgba(0,0,0, 1)',
  titleFontSize: 20,
  ifShowMapLegend: true,
  labelColor: '#999',
  legendColor: '#999',
};

export const Schema = {
  droppable: false,
  propsSchema: createInbizSchema({
    attribute: {
      base: {
        type: 'void',
        'x-component': 'CollapseItem',
        properties: {
          title: {
            type: 'object',
            'x-decorator': 'FormItem',
            'x-component': 'StatusInput',
          },
          'x-component-props': {
            type: 'object',
            properties: {
              values: {
                type: 'string',
                'x-decorator': 'FormItem',
                'x-component': 'BiValue',
                'x-component-props': {
                  multiple: false,
                },
              },
              mapLegend: {
                type: 'string',
                'x-decorator': 'FormItem',
                'x-component': 'BiAxis',
              },
              filter: {
                type: 'string',
                'x-decorator': 'FormItem',
                'x-component': 'BiFilter',
                'x-component-props': {
                  multiple: true,
                },
              },
              detailView: {
                type: 'string',
                enum: ['none', 'skip'],
                'x-decorator': 'FormItem',
                'x-component': 'Select',
                'x-component-props': {
                  defaultValue: 'none',
                },
              },
              detailViewHref: {
                type: 'string',
                'x-decorator': 'FormItem',
                'x-component': 'Input',
                'x-reactions': {
                  dependencies: ['.detailView'],
                  fulfill: {
                    schema: {
                      'x-hidden': "{{$deps[0] == 'none'}}",
                    },
                  },
                },
              },
            },
          },
        },
      },
    },
    style: {
      ...createComponentStyleSchema({
        ...createCommonMapStyle({ hasRatio: true, neeedAxis: false }),
        ...createBizStyleSchema(undefined, {}, undefined, undefined, false),
      }),
      ...createDecoratorStyleSchema(),
      ...createColorSchemeSchema(),
    },
    senior: {
      ...createMapSchema(),
    },
    controller:createControllerSchema({
      events: [{
        name:'onClick',
        label:'点击获取每项数据',
        platform:'web'
      },
      {
        name:'onParams',
        label:'请求前修改请求参数',
        platform:'web',
        isConfigEvent:true
      },
      {
        name:'onRequest',
        label:'自定义请求',
        platform:'web',
        isConfigEvent:true
      },
      {
        name:'onData',
        label:'格式化数据',
        platform:'web',
        isConfigEvent:true
      }
    ]
    })
  }),
};
